using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(ActiveObject))]
public class TaskTrigger : MonoBehaviour
{
   // [SerializeField] private string id;
    // [SerializeField] private NameLib getTaskName;
    [SerializeField] QuestChat quest;
    // [SerializeField] private bool startActive;

    // [SerializeField] private Task task;
    // private ObjectState n;
    private ActiveObject n;
    void Start()
    {
        n = gameObject.GetComponent<ActiveObject>();
        //n = PlayerData.FindObject(id);
        //if (n.id == null)
        //{
        //    n = PlayerData.AddObjectState(id, startActive); 
        //    gameObject.SetActive(startActive);
        //}
        //else
        //{
        //    gameObject.SetActive(n.isActive);
        //}
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            collision.GetComponent<ArtemDialog>().StartMonolog(quest);

            //n.isActive = false;
            //gameObject.SetActive(false);
            n.IsDisactive();
           // IsDisactive();
        }
    }

    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("Player"))
        {
            //collision.gameObject.GetComponent<ArtemDialog>().StartMonolog(getTaskName);
            collision.gameObject.GetComponent<ArtemDialog>().StartMonolog(quest);
        }
    }
    //public void IsActive()
    //{
    //    n.isActive = true;
    //    gameObject.SetActive(true);
    //}

    //public void IsDisactive()
    //{
    //    n.isActive = false;
    //    gameObject.SetActive(false);
    //    //Destroy(gameObject);
    //}
}
